import Vue from 'vue'
import App from './App.vue'
import router from "./router";
//import 'element-ui/lib/theme-chalk/index.css';
//import './piugins/element'
import './assets/fonts/iconfont.css'  //导入字体图标
import axios from 'axios'
import TreeTable from 'vue-table-with-tree-grid'    //树形表格

//导入富文本编辑器
import VueQuillEditor from 'vue-quill-editor'
Vue.use(VueQuillEditor)

//导入NProgress
import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

// 配置请求的跟路径   注意：如果配置路径发生改变，Add.vue里面图片上传的Url也要改变
//axios.defaults.baseURL = 'http://127.0.0.1:8888/api/private/v1/'
axios.defaults.baseURL='http://www.ysqorz.top:8888/api/private/v1/'
Vue.prototype.$http = axios
//axios请求拦截
  //在request拦截器中，展示进度条 NProgress.start()
axios.interceptors.request.use(config =>{
  NProgress.start()
  //为请求投对象，添加token验证的authorization字段
  config.headers.authorization = window.sessionStorage.getItem('token')
  return config
})
//在response拦截器中，隐藏进度条 NProgress.done
axios.interceptors.response.use(config => {
  NProgress.done()
  return config
})
//时间戳转换成时间
Vue.filter('dateFormat',function (originVal){
  const dt = new Date(originVal)

  const y =dt.getFullYear()
  const m = (dt.getMonth() + 1 +'').padStart(2,'0') //月份要加一，如果不是两位的话要在前面加一个0
  const d = (dt.getDate() + '').padStart(2,'0')

  const hh = (dt.getHours() + '').padStart(2,'0')
  const mm = (dt.getMinutes() + '').padStart(2,'0')
  const ss = (dt.getSeconds() + '').padStart(2,'0')

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`
})

Vue.config.productionTip = false

Vue.component('tree-table',TreeTable)
//导入全局样式表
import './assets/css/global.css'
new Vue({
  render: h => h(App),
  router,
}).$mount('#app')

